//package com.example.rabbitmqboot.consumer;
//
//import com.example.rabbitmqboot.pojo.Student;
//import com.rabbitmq.client.Channel;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.amqp.core.Message;
//import org.springframework.amqp.core.MessageProperties;
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
//import org.springframework.amqp.support.AmqpHeaders;
//import org.springframework.messaging.handler.annotation.Headers;
//import org.springframework.messaging.handler.annotation.Payload;
//import org.springframework.stereotype.Component;
//
//import java.io.ByteArrayInputStream;
//import java.io.File;
//import java.io.IOException;
//import java.nio.file.Files;
//import java.util.Map;
//import java.util.UUID;
//
//@Component
//@Slf4j
//public class FileConsumer {
//    @RabbitListener(queues = "FileQueue", messageConverter = "fileMessageConverter")
//    public void studentMessage(Message message, Channel channel) throws IOException {
//        MessageProperties messageProperties = message.getMessageProperties();
//        String contentType = messageProperties.getContentType();
//        StringBuffer stringBuffer = new StringBuffer();
//        stringBuffer.append("D:\\drugImg\\");
//        String fileName = UUID.randomUUID().toString();
//        switch (contentType) {
//            case "pdf":
//                log.info("pdf");
//                stringBuffer.append(fileName).append(".pdf");
//                break;
//            case "png":
//                log.info("png");
//                stringBuffer.append(fileName).append(".png");
//                break;
//        }
//
//        File file = new File(stringBuffer.toString());
//
//        //文件转存
//        Files.copy(new ByteArrayInputStream(message.getBody()), file.toPath());
//
//        //手动应答
//        channel.basicAck(messageProperties.getDeliveryTag(), false); //应答当前消息
//    }
//}
